package com.itheima.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.mapper.DeptMapper;
import com.itheima.pojo.Dept;
import com.itheima.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;


@Service
    public class DeptServiceImpl   extends ServiceImpl<DeptMapper,Dept> implements DeptService {
    @Autowired
    private DeptMapper deptMapper;

    @Override
    public List<Dept> findAll() {
        return deptMapper.selectList(null);
    }
    @Override
    public void deleteById(Integer id) {
        deptMapper.deleteById(id);
    }
    @Override
    public boolean save(Dept dept) {
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.insert(dept);
        return false;
    }
    @Override
    public  Dept getByid(Integer id){
        Dept dept = deptMapper.selectById(id);
        return dept;


    }
    @Override
    public  void update(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        // deptMapper.updateById(dept);
        deptMapper.update(dept);
    }

}
